package xyz.gzdxc.common.mysql.repository;

import org.springframework.data.jdbc.repository.query.Modifying;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import xyz.gzdxc.common.mysql.entity.UserEntity;

public interface UserRepository extends CrudRepository<UserEntity, Long> {
    /**
     * find the user according to account
     *
     * @param account
     * @return UserEntity
     */
    UserEntity findByAccount(String account);

    /**
     * update error_num and user_lock by id
     *
     * @param id
     * @param errorNum
     * @param userLock
     * @return boolean
     */
    @Modifying
    @Query("update xh_cm_user set error_num = :errorNum, user_lock = :userLock where id = :id")
    boolean updateErrorNumAndUserLockById(@Param("id") Long id, @Param("errorNum") Integer errorNum, @Param("userLock") String userLock);
}
